home *** CD-ROM | disk | FTP | other *** search
- Path: prairienet.org!sjmccaug
- From: sjmccaug@prairienet.org (Scott J. McCaughrin)
- Newsgroups: comp.lang.c++
- Subject: Re: pow(-1,1.1) = DOMAIN error
- Date: 23 Feb 1996 10:35:28 GMT
- Organization: University of Illinois at Urbana
- Message-ID: <4gk59g$mko@vixen.cso.uiuc.edu>
- References: <96053.171141DSEAMA41@portland.caps.maine.edu> <Christian.Straka.15.0010E3C9@uni-konstanz.de>
- Reply-To: sjmccaug@prairienet.org (Scott J. McCaughrin)
- NNTP-Posting-Host: firefly.prairienet.org
-
-
- In a previous article, DSEAMA41@portland.caps.maine.edu (Starduster) says:
-
- >In article <Christian.Straka.15.0010E3C9@uni-konstanz.de>,
- >Christian.Straka@uni-konstanz.de (Christian Straka) says:
- >>The pow() and powl() function in <math.h> doesn't work properly. The following
- >>example causes a DOMAIN error exception (see defs in math.h):
- >>
- >> pow(-1,1.1);
- >>
- >>Has anyone an idea to fix this problem?
- The problem lies in the way 'pow' is implemented via logarithms:
- pow(x,y) = (e^ln(x))^y = e^(y*ln(x)).
- So pow(-1,y) = e^(y*ln(-1)) which bombs because natural log (ln) can't take
- negative arguments (or 0) over the reals. That is, negatives and zero are
- not in the domain of ln.
-
- -- Scott
-
-